import api from '../../fetch/api'
import * as types from '../mutation-types';

const state = {
   news:[]
}

const actions = {
    get_news_list({ commit }) {
        api.get_news_list().then(res => {
            commit(types.GET_NEWS_LIST, res)
        })
    },
    getNewsTitle({ commit }, title) {
        commit('getNewsTitle',title)
    }
}

const getters = {
    news: state => state.news
   
}

const mutations = {
    [types.GET_NEWS_LIST](state, res) {
        state.news = res.data
    },
    getNewsTitle(state, payload) {
        state.news.name=payload
    }
}

export default {
    state,
    actions,
    getters,
    mutations,
}